package org.git.movie.service.impl;

import org.git.movie.entity.LogWebsiteVisit;
import org.git.movie.mapper.LogWebsiteVisitMapper;
import org.git.movie.service.ILogWebsiteVisitService;
import org.git.movie.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.IdGenerator;
import org.springframework.util.SimpleIdGenerator;

import java.util.UUID;

/**
 * @author sqyc
 */
@Service
public class LogWebsiteVisitServiceImpl implements ILogWebsiteVisitService {

    @Autowired
    private LogWebsiteVisitMapper logWebsiteVisitMapper;

    @Override
    public int insert(LogWebsiteVisit record) {

        String year = DateUtil.format(record.getCreateAt(),"yyyy");
        String yearMonth = DateUtil.format(record.getCreateAt(),"yyyy-MM");
        String yearMonthDay = DateUtil.format(record.getCreateAt(),"yyyy-MM-dd");
        String uuid = UUID.randomUUID().toString().replaceAll("-","");
        record.setId(uuid);
        record.setYear(year);
        record.setYearmonth(yearMonth);
        record.setYdate(yearMonthDay);
        return logWebsiteVisitMapper.insert(record);
    }
}
